package com.cap.bts.crmdp.dealer.mars.domain;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Type;

import com.cap.bts.framework.common.domain.BaseDomain;

@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Entity
@Table(name = "Tl_MARS_LOG")
public class MarsLog extends BaseDomain implements Serializable {

    private static final long serialVersionUID = 3292243745940975457L;

    private static final  String FORMAT = "yyyy-MM-dd HH:mm:ss";

    private Long id;

    private String paramText;
    private String paramTextEncrypt;

    private String returnText;
    private String returnTextEncrypt;

    private String successFlag;

    private String callType;
    private String callMethod;
    private String callTime;

    private String descp;

    public MarsLog() {

    }

    public MarsLog(String callType) {
        this.callType = callType;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Lob
    @Column(name = "PARAM_TEXT", columnDefinition="TEXT")
    public String getParamText() {
        return paramText;
    }

    public void setParamText(String paramText) {
        this.paramText = paramText;
    }

    @Lob
    @Column(name = "RETURN_TEXT", columnDefinition="TEXT")
    public String getReturnText() {
        return returnText;
    }

    public void setReturnText(String returnText) {
        this.returnText = returnText;
    }

    @Column(name = "SUCCESS_FLAG")
    public String getSuccessFlag() {
        return successFlag;
    }

    public void setSuccessFlag(String successFlag) {
        this.successFlag = successFlag;
    }

    @Column(name = "CALL_METHOD")
    public String getCallMethod() {
        return callMethod;
    }

    public void setCallMethod(String callMethod) {
        this.callMethod = callMethod;
    }

    @Column(name = "DESCP")
    public String getDescp() {
        return descp;
    }

    public void setDescp(String descp) {
        this.descp = descp;
    }

    @Lob
    @Column(name = "PARAM_TEXT_ENCRYPT", columnDefinition="TEXT")
    public String getParamTextEncrypt() {
        return paramTextEncrypt;
    }

    public void setParamTextEncrypt(String paramTextEncrypt) {
        this.paramTextEncrypt = paramTextEncrypt;
    }

    @Lob
    @Column(name = "RETURN_TEXT_ENCRYPT", columnDefinition="TEXT")
    public String getReturnTextEncrypt() {
        return returnTextEncrypt;
    }

    public void setReturnTextEncrypt(String returnTextEncrypt) {
        this.returnTextEncrypt = returnTextEncrypt;
    }

    @Column(name = "CALL_TYPE")
    public String getCallType() {
        return callType;
    }

    public void setCallType(String callType) {
        this.callType = callType;
    }

    @Transient
    public String getCallTime() {
        Date createTime = getCreateDate();
        if (createTime != null) {
            callTime = new SimpleDateFormat(FORMAT).format(createTime);
        }
        return callTime;
    }

    public void setCallTime(String callTime) {
        this.callTime = callTime;
    }

}
